load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "core",
    srcs = [
        "access_object.go",
        "collect_column_stats_usage.go",
        "common_plans.go",
        "debugtrace.go",
        "encode.go",
        "errors.go",
        "exhaust_physical_plans.go",
        "explain.go",
        "expression_rewriter.go",
        "find_best_task.go",
        "flat_plan.go",
        "foreign_key.go",
        "fragment.go",
        "handle_cols.go",
        "hashcode.go",
        "hints.go",
        "indexmerge_path.go",
        "initialize.go",
        "logical_plan_builder.go",
        "logical_plans.go",
        "memtable_predicate_extractor.go",
        "mock.go",
        "optimizer.go",
        "partition_prune.go",
        "pb_to_plan.go",
        "physical_plans.go",
        "plan.go",
        "plan_cache.go",
        "plan_cache_lru.go",
        "plan_cache_param.go",
        "plan_cache_utils.go",
        "plan_cacheable_checker.go",
        "plan_cost_detail.go",
        "plan_cost_ver1.go",
        "plan_cost_ver2.go",
        "plan_stats.go",
        "plan_to_pb.go",
        "planbuilder.go",
        "point_get_plan.go",
        "preprocess.go",
        "property_cols_prune.go",
        "resolve_indices.go",
        "rule_aggregation_elimination.go",
        "rule_aggregation_push_down.go",
        "rule_aggregation_skew_rewrite.go",
        "rule_build_key_info.go",
        "rule_column_pruning.go",
        "rule_decorrelate.go",
        "rule_derive_topn_from_window.go",
        "rule_eliminate_projection.go",
        "rule_generate_column_substitute.go",
        "rule_inject_extra_projection.go",
        "rule_join_elimination.go",
        "rule_join_reorder.go",
        "rule_join_reorder_dp.go",
        "rule_join_reorder_greedy.go",
        "rule_max_min_eliminate.go",
        "rule_partition_processor.go",
        "rule_predicate_push_down.go",
        "rule_predicate_simplification.go",
        "rule_push_down_sequence.go",
        "rule_resolve_grouping_expand.go",
        "rule_result_reorder.go",
        "rule_semi_join_rewrite.go",
        "rule_topn_push_down.go",
        "runtime_filter.go",
        "runtime_filter_generator.go",
        "scalar_subq_expression.go",
        "show_predicate_extractor.go",
        "stats.go",
        "stringer.go",
        "task.go",
        "telemetry.go",
        "tiflash_selection_late_materialization.go",
        "trace.go",
        "util.go",
    ],
    importpath = "github.com/pingcap/tidb/planner/core",
    visibility = ["//visibility:public"],
    deps = [
        "//bindinfo",
        "//br/pkg/storage",
        "//config",
        "//distsql",
        "//domain",
        "//errno",
        "//expression",
        "//expression/aggregation",
        "//infoschema",
        "//kv",
        "//lock",
        "//meta/autoid",
        "//metrics",
        "//parser",
        "//parser/ast",
        "//parser/auth",
        "//parser/charset",
        "//parser/format",
        "//parser/model",
        "//parser/mysql",
        "//parser/opcode",
        "//parser/terror",
        "//parser/types",
        "//planner/core/internal",
        "//planner/core/metrics",
        "//planner/funcdep",
        "//planner/property",
        "//planner/util",
        "//planner/util/debugtrace",
        "//planner/util/fixcontrol",
        "//privilege",
        "//sessionctx",
        "//sessionctx/stmtctx",
        "//sessionctx/variable",
        "//sessiontxn",
        "//sessiontxn/staleread",
        "//statistics",
        "//statistics/handle/cache",
        "//table",
        "//table/tables",
        "//table/temptable",
        "//tablecodec",
        "//telemetry",
        "//types",
        "//types/parser_driver",
        "//util",
        "//util/chunk",
        "//util/codec",
        "//util/collate",
        "//util/dbterror",
        "//util/dbterror/exeerrors",
        "//util/disjointset",
        "//util/domainutil",
        "//util/execdetails",
        "//util/filter",
        "//util/hack",
        "//util/hint",
        "//util/intest",
        "//util/kvcache",
        "//util/logutil",
        "//util/mathutil",
        "//util/memory",
        "//util/mock",
        "//util/paging",
        "//util/parser",
        "//util/plancache",
        "//util/plancodec",
        "//util/ranger",
        "//util/rowcodec",
        "//util/sem",
        "//util/set",
        "//util/size",
        "//util/sqlexec",
        "//util/stmtsummary",
        "//util/stringutil",
        "//util/syncutil",
        "//util/texttree",
        "//util/tiflashcompute",
        "//util/tracing",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_kvproto//pkg/coprocessor",
        "@com_github_pingcap_kvproto//pkg/diagnosticspb",
        "@com_github_pingcap_tipb//go-tipb",
        "@com_github_tikv_client_go_v2//kv",
        "@com_github_tikv_client_go_v2//oracle",
        "@com_github_tikv_client_go_v2//tikv",
        "@org_golang_x_exp//slices",
        "@org_uber_go_atomic//:atomic",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "core_test",
    timeout = "short",
    srcs = [
        "binary_plan_test.go",
        "cbo_test.go",
        "collect_column_stats_usage_test.go",
        "common_plans_test.go",
        "enforce_mpp_test.go",
        "errors_test.go",
        "exhaust_physical_plans_test.go",
        "expression_rewriter_test.go",
        "expression_test.go",
        "find_best_task_test.go",
        "fragment_test.go",
        "indexmerge_intersection_test.go",
        "indexmerge_path_test.go",
        "indexmerge_test.go",
        "integration_partition_test.go",
        "integration_test.go",
        "logical_plan_trace_test.go",
        "logical_plans_test.go",
        "main_test.go",
        "memtable_predicate_extractor_test.go",
        "optimizer_test.go",
        "partition_pruner_test.go",
        "partition_pruning_test.go",
        "physical_plan_test.go",
        "physical_plan_trace_test.go",
        "plan_cache_lru_test.go",
        "plan_cache_param_test.go",
        "plan_cache_test.go",
        "plan_cache_utils_test.go",
        "plan_cacheable_checker_test.go",
        "plan_cost_detail_test.go",
        "plan_cost_ver1_test.go",
        "plan_cost_ver2_test.go",
        "plan_replayer_capture_test.go",
        "plan_stats_test.go",
        "plan_test.go",
        "plan_to_pb_test.go",
        "planbuilder_test.go",
        "point_get_plan_test.go",
        "prepare_test.go",
        "preprocess_test.go",
        "rule_join_reorder_dp_test.go",
        "rule_join_reorder_test.go",
        "rule_result_reorder_test.go",
        "runtime_filter_generator_test.go",
        "stringer_test.go",
    ],
    data = glob(["testdata/**"]),
    embed = [":core"],
    flaky = True,
    shard_count = 50,
    deps = [
        "//config",
        "//domain",
        "//errno",
        "//executor",
        "//expression",
        "//expression/aggregation",
        "//infoschema",
        "//kv",
        "//metrics",
        "//parser",
        "//parser/ast",
        "//parser/auth",
        "//parser/charset",
        "//parser/format",
        "//parser/model",
        "//parser/mysql",
        "//parser/terror",
        "//planner",
        "//planner/core/internal",
        "//planner/property",
        "//planner/util",
        "//session",
        "//sessionctx",
        "//sessionctx/stmtctx",
        "//sessionctx/variable",
        "//sessiontxn",
        "//statistics",
        "//statistics/handle",
        "//table",
        "//testkit",
        "//testkit/ddlhelper",
        "//testkit/external",
        "//testkit/testdata",
        "//testkit/testmain",
        "//testkit/testsetup",
        "//testkit/testutil",
        "//types",
        "//types/parser_driver",
        "//util",
        "//util/benchdaily",
        "//util/chunk",
        "//util/collate",
        "//util/dbterror",
        "//util/hack",
        "//util/hint",
        "//util/kvcache",
        "//util/logutil",
        "//util/mock",
        "//util/plancache",
        "//util/plancodec",
        "//util/ranger",
        "//util/set",
        "//util/size",
        "//util/stmtsummary",
        "//util/tracing",
        "@com_github_golang_snappy//:snappy",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_tipb//go-tipb",
        "@com_github_prometheus_client_golang//prometheus",
        "@com_github_prometheus_client_model//go",
        "@com_github_stretchr_testify//require",
        "@org_golang_x_exp//slices",
        "@org_uber_go_goleak//:goleak",
    ],
)
